Repository navigation
Conversation
Setting the position or rotation of a moving NPC re-runs move() to aim it at its target again, but it passed only the target and move type, so the speed and stop range fell back to the defaults. An NPC told to walk at walking speed (auto type) started jogging after the first NPC_SetRot, and a driver moving at a custom speed jumped to speed 1.0. move() also wrote the speed into a local that shadowed the moveSpeed_ member, so the member was never set. Store it in the member and pass it, with stopRange_, from setPosition, setVehiclePosition, setRotation and setVehicleRotation.
|
Tested on top of master (72bf89c), NPCs only, going for the setters that aren't in your table. Same idea, A as the reference and B getting the setter every second, distance after 6.5 s: So the stop range is kept too, on master B went 19.7 of the 20 m instead of stopping 8 m before the target. The small gap that's left (B a bit behind A, it's in your numbers too) comes from move() setting lastMove_ to now, so every setter call drops the time since the last update. Not a big deal, just saying where it comes from. LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calling
NPC_SetPos,NPC_SetRot,NPC_SetVehiclePosorNPC_SetVehicleRoton a moving NPC resets the speed and stop range it was given inNPC_Move.The setters re-run
move(targetPosition_, moveType_)to aim the NPC at its target again, but they don't pass the speed or the stop range, so the defaults are used.move()also wrote the speed into a localfloat moveSpeed_that shadowed the member, so the member never had the speed to pass anyway.In game:
NPC_MOVE_TYPE_AUTO, NPC_MOVE_SPEED_WALKstarts jogging after the firstNPC_SetRotNPC_MOVE_TYPE_DRIVE, 0.3speeds up to the default 1.0 afterNPC_SetVehicleRotThis stores the speed in the member and passes
moveSpeed_andstopRange_from the four setters.Test
A and B get the same
NPC_Move. Every 2 s, B is given the rotation it already has. Distance covered:The on-foot case in game:
repro.pwn
Tested on a 1.6.7 server with the NPCs component built from master and from this branch.